package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TThesis;
import com.ruoyi.system.service.ITThesisService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 涉密学位论文篇数Controller
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/system/thesis")
public class TThesisController extends BaseController
{
    @Autowired
    private ITThesisService tThesisService;

    /**
     * 查询涉密学位论文篇数列表
     */
    @PreAuthorize("@ss.hasPermi('system:thesis:list')")
    @GetMapping("/list")
    public TableDataInfo list(TThesis tThesis)
    {
        startPage();
        List<TThesis> list = tThesisService.selectTThesisList(tThesis);
        return getDataTable(list);
    }

    /**
     * 导出涉密学位论文篇数列表
     */
    @PreAuthorize("@ss.hasPermi('system:thesis:export')")
    @Log(title = "涉密学位论文篇数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TThesis tThesis)
    {
        List<TThesis> list = tThesisService.selectTThesisList(tThesis);
        ExcelUtil<TThesis> util = new ExcelUtil<TThesis>(TThesis.class);
        util.exportExcel(response, list, "涉密学位论文篇数数据");
    }

    /**
     * 获取涉密学位论文篇数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:thesis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tThesisService.selectTThesisById(id));
    }

    /**
     * 新增涉密学位论文篇数
     */
    @PreAuthorize("@ss.hasPermi('system:thesis:add')")
    @Log(title = "涉密学位论文篇数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TThesis tThesis)
    {
        return toAjax(tThesisService.insertTThesis(tThesis));
    }

    /**
     * 修改涉密学位论文篇数
     */
    @PreAuthorize("@ss.hasPermi('system:thesis:edit')")
    @Log(title = "涉密学位论文篇数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TThesis tThesis)
    {
        return toAjax(tThesisService.updateTThesis(tThesis));
    }

    /**
     * 删除涉密学位论文篇数
     */
    @PreAuthorize("@ss.hasPermi('system:thesis:remove')")
    @Log(title = "涉密学位论文篇数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tThesisService.deleteTThesisByIds(ids));
    }
}
